<?php namespace Modules\Web\Http\Controllers;

use Pingpong\Modules\Routing\Controller;

class ApiController extends Controller {
	
	public function index()
	{
        define('IN_ECS', true);

        require(dirname(__FILE__) . '/includes/init.php');
        require(ROOT_PATH . 'includes/lib_license.php');
        require_once('includes/cls_json.php');

        define('RETURN_TYPE', empty($_POST['return_data']) ? 1 : ($_POST['return_data'] == 'json' ? 2 : 1));

        /* 接收传递参数并初步检验 */
        if (empty($_POST) || empty($_POST['ac']))
        {
            api_err('0x003', 'no parameter');   //输出系统级错误:数据异常
        }

        /* 根据请求类型进入相应的接口处理程序 */
        switch ($_POST['act'])
        {
            case 'search_goods_list': search_goods_list(); break;
            case 'search_goods_detail': search_goods_detail(); break;
            case 'search_deleted_goods_list': search_deleted_goods_list(); break;
            case 'search_products_list': search_products_list(); break;
            case 'search_site_info': search_site_info(); break;
            default: api_err('0x008', 'no this type api');   //输出系统级错误:数据异常
        }

		return view('web::index');
	}
	
}